package com.zgkxzx.sourceanasys;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.zgkxzx.sourceanasys.bean.BaseEvent;
import com.zgkxzx.sourceanasys.bean.FirstEvent;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.io.IOException;
import java.util.concurrent.TimeUnit;


public class MainActivity extends AppCompatActivity {
    private final static String TAG = MainActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        EventBus.getDefault().register(this);
    }




    @Subscribe
    public void onMainEvent(FirstEvent eventBean) {
        Toast.makeText(this, "FirstEvent--> " + eventBean.msg, Toast.LENGTH_SHORT).show();
        Log.d(TAG, "FirstEvent ");
    }


    @Subscribe
    public void onMainEvent(BaseEvent eventBean) {
        Toast.makeText(this, "BaseEvent--> " + eventBean.tag, Toast.LENGTH_SHORT).show();
        Log.d(TAG, "BaseEvent ");
    }

    public void onMsgSendClickEvent(View view) {
        EventBus.getDefault().post(new FirstEvent("nihao-->"));
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
